package ui.filter;

import java.util.Calendar;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

import dao.EgnProduct;
import dao.EgnRstScenarioId;


public class EntityFilter extends ViewerFilter {
	private String searchString;

	public void setSearchText(String s) {
		// Search must be a substring of the existing value
		this.searchString = ".*" + s + ".*";
		
	}
	
	@Override
	public boolean select(Viewer viewer, Object parentElement, Object element) {
		
		if (searchString == null || searchString.length() == 0) {
			return true;
		}
		
		else if( element instanceof EgnProduct){
			EgnProduct prod = (EgnProduct) element;
			if( prod.getProductId().matches(searchString)
					|| prod.getProductType().matches(searchString)){
				return true;
			}
		}
		return false;

	}

}
